#include "tree.h"
#include <stdlib.h>

tree * init_tree(tree * wtree, int data) 
{
	wtree = malloc(sizeof(tree)); 
	item * ditem = malloc(sizeof(item));
	ditem->data = data;
	wtree->root = ditem;
	return wtree;
}
tree * insert_tree(tree * wtree, int data)
{
	item * ditem = malloc(sizeof(item));
	item * wroot = wtree->root;
	ditem->data = data;

	while(wroot) {
		if(wroot->data > data) {
			if(wroot->right != NULL) {
				wroot = wroot->right;
			} else {
				wroot->right = ditem;
				break;
			}
		} else {
			if(wroot->left != NULL) {
				wroot = wroot->left;
			} else {
				wroot->left = ditem;
				break;
			}
		}
	}

	return wtree;
	
}
tree * delete_tree(tree * wtree, int data)
{
}
tree * find_tree(tree * wtree, int  data)
{
}

